package spsu.swe6733.assignment2;

import java.util.Scanner;

public class SumProgram {

	public static void main(String[] args) {
		
		String input;
	    PositiveInteger pInt = new PositiveInteger();	    
		
	    Scanner in = new Scanner(System.in);
	    
	    System.out.println("The program returns the sum of all integers between 1 and n.");
		System.out.println("Enter a positive interger.");
		
		do
		{
			input = in.nextLine();															//Reads input
			pInt.setN(input);							                            		//Validates input as positive integer and set n
			
			if(pInt.getN() > 0)																//Condition to exit loop is a positive integer
			{
				pInt.setValid();
				in.close();
			}
			
		}while (!pInt.isValid());
		
				
		System.out.println("Loop Sum: " + pInt.loopSum()); 				    			// Runs the loopSum method	
		System.out.println("Recursive Sum: " + pInt.recursiveSum(pInt.getN()));			//Runs the recursiveSum method
		System.out.println("Arithmetic Sum: " + pInt.arithmeticSum());					//Runs the arithemeticSum method
	    
	}	
}